﻿#ifndef UDPCLIENT_H
#define UDPCLIENT_H

#include <QObject>
#include <QHostAddress>
#include <QUdpSocket>
#include <QDebug>
#include "ComBase.h"

class UdpClient : public ComBase
{
    Q_OBJECT
public:
    explicit UdpClient(QObject *parent = nullptr);
    ~UdpClient(){}

public slots:
    virtual void onInit() override;
    virtual void onQuit() override;

protected:
    virtual void writeData(const QByteArray& data) override;
    virtual void disconnect() override;
    virtual void onReadyRead() override;
    virtual void processData(const QByteArray& data) override;
    void onStateChanged(QAbstractSocket::SocketState socketState);
    void onErrorOccurred(QAbstractSocket::SocketError error);
protected:
    QUdpSocket* mUdpSocket;//UDP套接字对象
};

#endif // UDPCLIENT_H
